<div class="nav">
    <a href="{:U('index')}">菜单列表</a>
    <a class="sel" href="#">编辑菜单</a>
</div>
<div class="add">
    <form method="post" action="" >
        <table class="table_add">
            <tr>
                <td width="100px">所属父级</td>
                <td><select name="parent_id" id="parent_id" class="sel1">
                        <option value="0">顶级类别</option>
                        <foreach name="parentList" item="item">
                            <option value="{$item.menu_id}" >{$item.menu_name}</option>
                        </foreach>
                    </select>
                </td>
            </tr>
            <tr>
                <td width="100px">菜单名称</td>
                <td><input class="input1" type="text" name="menu_name" id="menu_name" value="{$model.menu_name}" style="width:140px" /> </td>
            </tr>
            <tr>
                <td width="100px">菜单类型</td>
                <td><select name="menu_type" id="menu_type" class="sel1">
                        <option value="0">类别菜单</option>
                        <option value="1">实际操作菜单</option>
                    </select> <label class="msg">类别菜单没有菜单链接，自动获取最前一个实际操作菜单链接</td>
            </tr>
            <tr id="tr_link" style="display:none;">
                <td width="100px">菜单链接</td>
                <td><input class="input1" type="text" name="menu_link" id="menu_link" value="{$model.menu_link}" style="width:400px" /> <label class="msg">{模块名}/{操作名}?{参数}</label></td>
            </tr>
            <tr id="tr_purview" style="display:none;">
                <td width="100px">特殊权限名</td>
                <td><input class="input1" type="text" name="purview" id="purview" value="{$model.purview}" style="width:140px" /> <label class="msg">默认不用填写，系统根据权限表和菜单链接自动判断</label></td>
            </tr>
            <tr id="tr_target" style="display:none;">
                <td width="100px">打开方式</td>
                <td><select name="target" id="target" class="sel1">
                        <option value="">框架内</option>
                        <option value="_blank">新窗口</option>
                    </select></td>
            </tr> 
            <tr id="tr_index" style="display:none;">
                <td width="100px">首页推荐</td>
                <td><select name="is_index" id="is_index" class="sel1">
                        <option value="0">不推荐</option>
                        <option value="1">推荐</option>    
                    </select>
                </td>
            </tr>
           <tr id="tr_ico" style="display:none">
                <td width="100px">首页图标</td>
                <td><span id="show_ico" style="font-size:24px;"><span class="glyphicon {$model.ico}"></span></span> 
                    <input type="hidden" name="ico" id="ico" value="{$model.ico}" />
                    <input type="button" onclick="select_ico()" value="选择图标" />
                </td>
            </tr>
            <tr>
                <td width="100px">顺序编号</td>
                <td><input class="input1" type="text" name="order_id" id="order_id" value="{$model.order_id}" style="width:60px" /> <label class="msg">*</label></td>
            </tr>
            <tr>
                <td width="100px">是否启用</td>
                <td><select name="is_enable" id="is_enable" class="sel1">
                        <option value="1">启用</option>
                        <option value="0">不启用</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" class="btn1" value="提 交" /> &nbsp; <input class="btn4" type="reset" value="重 置" /> &nbsp; <input class="btn3"  type="button" onclick="window.history.back()" value="返 回" /></td>
            </tr>
        </table>
        <input type="hidden" name="menu_id" id="menu_id" value="{$model.menu_id}" />
    </form>
</div>
<script src="__PUBLIC__/common/artDialog4.1.7/artDialog.source.js?skin=blue" type="text/javascript"></script>
<script src="__PUBLIC__/common/artDialog4.1.7/plugins/iframeTools.source.js" type="text/javascript"></script>
<script type="text/javascript">
    function changeMenuType()
    {
        var menu_type = $("#menu_type").val();
        if (menu_type == 1)
        {
            $("#tr_link").show();
            $("#tr_purview").show();
            $("#tr_target").show();
            $("#tr_index").show();
        } else {
            $("#tr_link").hide();
            $("#tr_purview").hide();
            $("#tr_target").hide();
            $("#tr_index").hide();
        }
    }
    $("#parent_id").val("{$model.parent_id}");
    $("#menu_type").val("{$model.menu_type}");
    $("#target").val("{$model.target}");
    $("#is_enable").val("{$model.is_enable}");
    $("#is_index").val("{$model.is_index}");
    $("input[name=ico]").each(function () {
        if($(this).val()=='{$model.ico}')
            $(this).attr("checked","checked");
    });
    changeMenuType();
    $("#menu_type").change(function() {
        changeMenuType();
    });
    
    //选择图标
    var url_sel_ico = "{:U('ico')}";
    function select_ico() {
        art.dialog.open(url_sel_ico, {title: "选择图标", width: "820px", height: "550px"});
    }
    
    function show_ico(ico) {
        $("#show_ico").html('<span class="glyphicon '+ico+'"></span>');
        $("#ico").val(ico);
    }

</script>
